import os
path = os.getcwd()+"\\ストパニもの\\"
dirs = os.listdir(path+"NativeScript\\")
for dir in dirs:
    print(dir)
    list = []
    f1 = open(path+"NativeScript\\"+dir,"r",encoding='shift_jisx0213')
    text_lines = f1.readlines()
    for line in text_lines:
        if "*title_start" in line:
            #list.append("label "+line[12:len(line)-1]+":")
            continue
        if "goto" in line:
            #list.append(line[5:len(line)-1])
            continue
        if ";SE：" in line:
            #list.append("voice \""+line[4:len(line)-1]+".ogg\"")
            continue
        if "[" in line:#立绘、语音
            list.append("voice \"audio/"+line[line.rfind("/")+1:line.rfind("]")]+".ogg\"")
            if line[1] == "蕾":
                list.append("tu ")
                continue
            elif line[1] == "夜":
                list.append("ya ")
                continue
            elif line[1] == "渚":
                list.append("na ")
                continue
            else :
                list.append("ta ")
                continue
        if "bg" in line:#背景
            if "ev" in line:
                list.append("scene bg "+line[line.rfind("ev/ev")+3:line.rfind(".")])
                continue
            elif "bg/bg" in line:
                list.append("scene bg "+line[line.rfind("bg/bg")+3:line.rfind(".")])
                continue
            else:
                list.append("scene "+line[0:line.rfind(",")])
                continue
        if ";cg" in line:
            list.append(line[4:len(line)-1])
            continue
        if "mp3loop" in line:
            list.append("play music \"audio/"+line[line.rfind("me/")+3:len(line)-1])
            continue
        if "「" in line:
            list.append("\""+line[line.rfind("「")+1:line.rfind("」")]+"\"")
            continue
        if line[0] != "\n" and line[0] != "b" and line[0] != ";" and line[0] != "「" and line[0] != "[" and line[0] != "	" and line[0] != "m" and line[0] != "q" and line[0] != "g" and line[0] != "*":
            list.append(line[:len(line)-1])
            continue
        for text in list:
            print(text)
    f1.close()
    with open(path+"RenpyOriginalScript\\"+dir,"w",encoding="utf-8") as f2:
        for ScriptText in list:
            f2.write(ScriptText+"\n")